﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Collections;
using log4net;
using WEB.DAL.DBManagers;
using WEB.BLL.Entities;
using WEB.Exceptions;

namespace WEB.BLL.Services
{
    #region Dashboard

    /// <summary>
    /// DashboardService object for Ibatis mapped table 'Dashboard'.
    /// </summary>
    public class IDashboardService : BaseSqlMapDao
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(IDashboardService).Name);
        public IList<DashboardEntity> LoadAll()
        {
            try
            {
                return ExecuteQueryForList<DashboardEntity>("DashboardLoadAll", null);
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
        public DashboardEntity LoadByPrimaryKey(DashboardEntity objE)
        {
            try
            {
                return ExecuteQueryForObject<DashboardEntity>("DashboardLoadByPrimaryKey", objE);
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
        /// <summary>
        /// add new Dashboard to DB 
        /// </summary>
        /// <param name="objE"></param>
        /// <returns></returns>
        public int Insert(DashboardEntity objE)
        {
            try
            {
                ExecuteInsert("DashboardInsert", objE);
                return 1;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
        /// <summary>
        /// update Dashboard to DB 
        /// </summary>
        /// <param name="objE"></param>
        /// <returns></returns>
        public int Update(DashboardEntity objE)
        {
            try
            {
                ExecuteUpdate("DashboardUpdate", objE);
                return 1;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
        /// <summary>
        /// delete Dashboard to DB 
        /// </summary>
        /// <param name="objE"></param>
        /// <returns></returns>
        public int Delete(DashboardEntity objE)
        {
            try
            {
                ExecuteDelete("DashboardDelete", objE);
                return 1;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
    }
    #endregion
}
